import React from 'react'
import { useList } from '../../context/ListProvider';

const Item = ({item}) => {
    const {dispatch} = useList()

    const deleteItem = ()=>{
        dispatch({type:'delete_item',id:item.id})
    }
  return (
    <li key={item.id}>
        {item.title}
        <button onClick={deleteItem}>删除</button>
    </li>
  )
}

export default Item